package ${package.Controller};


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import com.xiao.hao.config.CheckParamsAnnotation;
import com.xiao.hao.constant.CheckParamsEnum;
import com.xiao.hao.utils.PageResult;
import com.xiao.hao.utils.Result;
import ${package.Entityinsert}.${entity}InsertReq;
import ${package.Entitypagereq}.${entity}QueryPageReq;
import ${package.Entityupdate}.${entity}UpdateReq;
import ${package.Service}.${table.serviceName};
import com.xiao.hao.utils.BaseId;

/**
*
*
* @Description ${table.comment!} controller层
* @Author ${author}
* @Date ${date}
*/

@Api(tags = "${table.comment!}控制层")
@RestController
@Slf4j
@RequestMapping("<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
 class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
public class ${table.controllerName} {


    @Resource
    private ${table.serviceName} facade;

    @ApiOperation(value = "新增")
    @PostMapping("insert")
    @CheckParamsAnnotation(CheckParamsEnum.INSERT_CHECK)
    public Result insert(@RequestBody ${entity}InsertReq req) {
      return facade.insert(req);
    }

    @ApiOperation(value = "编辑")
    @PostMapping("update")
    @CheckParamsAnnotation(CheckParamsEnum.UPDATE_CHECK)
    public Result update(@RequestBody ${entity}UpdateReq req) {
      return facade.update(req);
    }

    @PostMapping("delete")
    @ApiOperation(value = "删除")
    public Result delete(@RequestBody BaseId req) {
      return facade.delete(req);
    }

    @ApiOperation(value = "分页查询")
    @PostMapping("queryPage")
    public PageResult queryPage(@RequestBody ${entity}QueryPageReq req) {
      return facade.queryPage(req);
    }

<#--    @ApiOperation(value = "查询")-->
<#--    @PostMapping("queryAll")-->
<#--    public Result queryAll() {-->
<#--      return facade.queryAll();-->
<#--    }-->

}
</#if>


<#--/**-->
<#-- * <p>-->
<#-- * ${table.comment!} 前端控制器-->
<#-- * </p>-->
<#-- *-->
<#-- * @author ${author}-->
<#-- * @since ${date}-->
<#-- */-->
<#--<#if restControllerStyle>-->
<#--@RestController-->
<#--<#else>-->
<#--@Controller-->
<#--</#if>-->
<#--@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")-->
<#--<#if kotlin>-->
<#--class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>-->
<#--<#else>-->
<#--<#if superControllerClass??>-->
<#--public class ${table.controllerName} extends ${superControllerClass} {-->
<#--<#else>-->
<#--public class ${table.controllerName} {-->
<#--</#if>-->

<#--}-->
<#--</#if>-->
